<?php 
declare (strict_types = 1);
namespace app\api\controller;
use app\common\controller\Api;
use think\Request;
class BusinessReport extends Api
{
    protected $with = ['business_report_detailed.business_money_type','business'];
    public function index()
    {
        $post = param();
        if(isset($post['where']) && !empty($post['where']) && is_array($post['where'])){
            foreach ($post['where'] as $k=>$v){
                if(is_array($v)){
                    if(isset($v['key']) && isset($v['value'])){
                        if(isset($v['i'])){
                            $this->where[] = [$v['key'],$v['i'],$v['value']];
                        }else{
                            $this->where[] = [$v['key'],'=',$v['value']];
                        }
                    }
                }else{
                    $this->where[] = [$k,'=',$v];
                }
            }
        }
        $this->order = $post['order'] ?? $this->order;
        $this->limit = $post['limit'] ?? $this->limit;
        $this->field = $post['field'] ?? $this->field;
        $data = $this->model->where($this->where)->order($this->order)->with($this->with)->field($this->field)->select();
        if(!empty($data) && !empty($data->toArray()))
        {
            $data = $data->toArray();
        }
        return datasuccess($data);
    }
}